.class public Lorg/microemu/cldc/socket/Connection;
.super Ljava/lang/Object;
.source "Connection.java"

# interfaces
.implements Lorg/microemu/cldc/ClosedConnection;


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 31
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


# virtual methods
.method public close()V
    .locals 0
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 52
    return-void
.end method

.method public open(Ljava/lang/String;)Ljavax/microedition/io/Connection;
    .locals 5
    .parameter "name"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 35
    invoke-static {}, Lorg/microemu/cldc/http/Connection;->isAllowNetworkConnection()Z

    move-result v3

    if-nez v3, :cond_0

    .line 36
    new-instance v3, Ljava/io/IOException;

    const-string v4, "No network"

    invoke-direct {v3, v4}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw v3

    .line 39
    :cond_0
    const/16 v3, 0x3a

    invoke-virtual {p1, v3}, Ljava/lang/String;->lastIndexOf(I)I

    move-result v2

    .line 40
    .local v2, portSepIndex:I
    add-int/lit8 v3, v2, 0x1

    invoke-virtual {p1, v3}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I

    move-result v1

    .line 41
    .local v1, port:I
    const-string v3, "socket://"

    invoke-virtual {v3}, Ljava/lang/String;->length()I

    move-result v3

    invoke-virtual {p1, v3, v2}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v0

    .line 43
    .local v0, host:Ljava/lang/String;
    invoke-virtual {v0}, Ljava/lang/String;->length()I

    move-result v3

    if-lez v3, :cond_1

    .line 44
    new-instance v3, Lorg/microemu/cldc/socket/SocketConnection;

    invoke-direct {v3, v0, v1}, Lorg/microemu/cldc/socket/SocketConnection;-><init>(Ljava/lang/String;I)V

    .line 46
    :goto_0
    return-object v3

    :cond_1
    new-instance v3, Lorg/microemu/cldc/socket/ServerSocketConnection;

    invoke-direct {v3, v1}, Lorg/microemu/cldc/socket/ServerSocketConnection;-><init>(I)V

    goto :goto_0
.end method
